package br.com.gaacorp.sai.model;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Entity
@Table(name = "tab_college")
public class College extends BaseObject implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8679620274952200813L;
	private Long collegeId;
	private String name;
	private String description;
	private University university;
	
	@ManyToOne(optional=false)
	@OnDelete(action=OnDeleteAction.CASCADE)
	public University getUniversity() {
		return university;
	}

	public void setUniversity(University university) {
		this.university = university;
	}

	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (!(o instanceof College)) {
			return false;
		}

		final College college = (College) o;

		return !(name != null ? !name.equals(college.name)
				: college.name != null);
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getCollegeId() {
		return collegeId;
	}

	public String getDescription() {
		return description;
	}

	public String getName() {
		return name;
	}

	public int hashCode() {
		return (name != null ? name.hashCode() : 0);
	}

	public void setCollegeId(Long collegeId) {
		this.collegeId = collegeId;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE).append(
				this.name).toString();
	}

}
